import unittest
import os.path
import time
from HTMLTestRunner import HTMLTestRunner

# locale
locale = unittest.defaultTestLoader.discover('./test_cases','test*')

# 准备写入的文件
report = os.path.abspath('report')
filename = time.strftime('%Y%m%d%H%M%S') + '-demo.html'
filepath = os.path.join(report,filename)

# 打开文件
f = open(filepath,mode='wb')

runner = HTMLTestRunner(
    title='购物车增删改查',
    description='测试报告描述',
    tester='桂伊凡,尹开力,罗乐,李轩宇,阮继鹏',
    stream=f,
    verbosity=2
)
runner.run(locale)
# 关闭文件
f.close()




